package demo1;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

public class UpdateStudent {
    public static void update(Connection connection , int id , String name) throws SQLException {
        String sql = "update student set  name=? where id=?";
        PreparedStatement statement = connection.prepareStatement(sql);
        statement.setString(1,name);
        statement.setInt(2,id);
        if(statement.executeUpdate()>=1){
            System.out.println("修改成功");
        }else {
            System.out.println("修改失败");
        }
    }
}
